using System.Collections.Generic;
using UnityEngine;
using System.IO;
#if UNITY_EDITOR
using UnityEditor;
#endif

namespace GameDesigner
{
    public class AnimationClipReference : ScriptableObject, IAnimationClipReference
    {
        [SerializeField] private List<string> clipNames;
        public List<string> ClipNames { get => clipNames; set => clipNames = value; }

#if UNITY_EDITOR
        [MenuItem("Assets/GameDesigner/State Machine/Create AnimationClipReference")]
        public static void CreateAssetBundleBuilder()
        {
            var animationClipReference = CreateInstance<AnimationClipReference>();
            var path = AssetDatabase.GetAssetPath(Selection.activeObject);
            if (string.IsNullOrEmpty(path))
                path = "Assets";
            else if (Path.GetExtension(path) != "")
                path = path.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), "");
            var assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path + "/AnimationClipReference.asset");
            AssetDatabase.CreateAsset(animationClipReference, assetPathAndName);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            EditorUtility.FocusProjectWindow();
            Selection.activeObject = animationClipReference;
        }
#endif
    }
}